
// Copyright (C) 2007 Richard Uhler
// This file is part of Esiply.
//
// Esiply is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, Version 2,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef _HOST_VALUE_H_
#define _HOST_VALUE_H_

// A HostValue represents a javascript value to the Host. It
// can convert that value to and from strings, numbers, booleans,
// or objects with host data.

#include <iostream>

#include "HostContext.h"
#include "HostValueType.h"
#include "Value.h"

class HostValue
{
public:
    HostValue();
    HostValue(const HostValue& rhs);

    // Create a function value
    HostValue(HostContext context, const char* params, 
            HostValue (*fp)(HostContext));

    // Create a number
    HostValue(double val);

    // Create a string
    HostValue(const char* str);
    HostValue(const char* str, int len);

    const char* c_str() const;
    HostValueType type() const;

    bool isException() const;


    // TODO: not for host to use, this stuff is internal!
    Value* get_value() const; 
    HostValue(Value* val);
    void set_value(Value* val);

    friend std::ostream& operator<<(std::ostream& outs, const HostValue& rhs);

private:
    Value* m_value;
};

#endif//_HOST_VALUE_H_

